import axios from "@/api/config"
import {baseURL} from "@/api/ipconfig"

var ip = baseURL.URL1

export const uploadAvatar = data => axios.post(ip + '/ubom/system/upload', data)

export const login = data => axios.post(ip+'/ssea/system/login', data)  //用户登陆接口

export async function outlogin() { //用户退出登陆
    const url = ip+'/ubom/system/logout' + "?refreshToken=" + localStorage.getItem("refreshToken");
    const res = await axios.post(url);
    return res.data;
}

export async function getuserLabelList() {//获取默认标签
    const url =ip+'/ssea/userLabels/default';
    let res = await axios.get(url);
    return res.data;
}

export async function saveLabel(data) {//保存选择的默认标签
    const url =ip+'/ssea/userLabels/select';
    let res = await axios.post(url,data);
    return res.data;
}
export async function checkMobile(data) {//校验手机号
    const url = ip+'/ubom/system/check/mobile?mobile='+data.mobile+'&smsCode='+data.smsCode;
    const res = await axios.get(url);
    return res.data;
}
export const getCode = data => axios.put(ip+'/ubom/system/verifyCode', data)  //获取短信验证码

export async function updateMobile(data) {//修改手机号
    const url = ip+'/ubom/portal/newMobile?mobile='+data.newMobile+'&verifyCode='+data.verifyCode;
    const res = await axios.put(url);
    return res.data;
}
export async function forgetPassword(data) { //忘记密码  手机号修改密码
    const url =ip+'/ubom/system/phone/password?mobile='+data.mobile+'&password='+data.password+'&verifyCode='+data.verifyCode;
    const res = await axios.put(url);
    return res.data;
}
export async function getUserInfo() {//获取用户信息
    const url =ip+'/ssea/userLabels/userInfo';
    let res = await axios.get(url);
    return res.data;
}
export async function saveLabelInput(data) {//保存输入标签
    const url =ip+'/ssea/userLabels/input';
    let res = await axios.post(url,data);
    return res.data;
}

export async function deleteLabelInput(data) {//删除输入标签
    const url =ip+'/ssea/userLabels/'+data;
    let res = await axios.delete(url,data);
    return res.data;
}

export async function saveUserInfo(data){
    const url = ip+'/ssea/userLabels/userInfo?email='+ data.email + '&photo='+data.photo;
    const res = await axios.put(url, data);
    return res.data;
}